Skip to content

fix: escape fallback raw-content text nodes#32

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix/raw-content-ancestor-close-xss
Open

fix: escape fallback raw-content text nodes#32
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix/raw-content-ancestor-close-xss

Conversation

@SkyZeroZx

@SkyZeroZx SkyZeroZx commented Jun 22, 2026

Copy link
Copy Markdown

Escape text nodes in iframe, noembed, noscript, and noframes during HTML serialization instead of emitting attacker-controlled bytes as raw markup.

These fallback raw-content elements are inert when parsed directly by a browser, but SSR post-processing can reparse serialized HTML without preserving raw-content parser state. Escaping their text nodes prevents ancestor-closing payloads from being emitted as executable markup while preserving raw serialization for script, style, xmp, and plaintext.

More context
https://issuetracker.google.com/u/1/issues/525899990 ( marked as duplicated , due it was marked as a duplicate of my first report )

@alan-agius4 Could you please check it?

EDIT : Traceability is now available at https://issuetracker.google.com/u/1/issues/525782033

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests indicate this fix introduces a regression with comments. For instance, <noscript><!-- something --></noscript> becomes escaped <noscript>&lt;!-- something --&gt;</noscript>. Although not dangerous, it changes the semantics by rendering a comment as active text which is incorrect.

@SkyZeroZx SkyZeroZx force-pushed the fix/raw-content-ancestor-close-xss branch 2 times, most recently from c1781e6 to 9243756 Compare June 23, 2026 12:33
@SkyZeroZx SkyZeroZx requested a review from alan-agius4 June 23, 2026 12:57
Escape text nodes in iframe, noembed, noscript, and noframes during HTML serialization instead of emitting attacker-controlled bytes as raw markup.

These fallback raw-content elements are inert when parsed directly by a browser, but SSR post-processing can reparse serialized HTML without preserving raw-content parser state. Escaping their text nodes prevents ancestor-closing payloads from being emitted as executable markup while preserving raw serialization for script, style, xmp, and plaintext.
@SkyZeroZx SkyZeroZx force-pushed the fix/raw-content-ancestor-close-xss branch from 9243756 to f56a381 Compare June 23, 2026 17:20
@SkyZeroZx

Copy link
Copy Markdown
Author

The tests indicate this fix introduces a regression with comments. For instance, <noscript><!-- something --></noscript> becomes escaped <noscript>&lt;!-- something --&gt;</noscript>. Although not dangerous, it changes the semantics by rendering a comment as active text which is incorrect.

@alan-agius4 Updated, regression tests were also added for the case of comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants